package me.flyray.netty.handlers;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel;

/** 
* @author: bolei
* @date：2018年9月11日 下午1:20:37 
* @description：类说明
*/

public class NettyChannelMap {
	
	private static Map<String, SocketChannel> map = new ConcurrentHashMap<String, SocketChannel>();
	  public static void add(String clientId,SocketChannel socketChannel){
 
	        map.put(clientId,socketChannel);
 
	    }
 
	    public static SocketChannel get(String clientId){
 
	       return map.get(clientId);
 
	    }
 
	    public static void remove(SocketChannel socketChannel){
 
	        for (Map.Entry entry:map.entrySet()){
 
	            if (entry.getValue()==socketChannel){
 
	                map.remove(entry.getKey());
 
	            }
 
	        }
 
	    }
 
}

